/**
 * 
 */
package com.geezdata.cps.ttk_admin.api.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.geezdata.cps.base.annotation.LoggerOut;
import com.geezdata.cps.base.response.BaseResponse;
import com.geezdata.cps.cqrs.command.Command;
import com.geezdata.cps.cqrs.command.bus.CommandBus;
import com.geezdata.cps.ttk.common.request.QuerySharerListRequest;
import com.geezdata.cps.ttk.common.request.UpdateSharerRequest;
import com.geezdata.cps.ttk.common.response.QuerySharerListResult;
import com.geezdata.cps.ttk.query.query.SharerService;

/**
 * @author sszheng
 * @date 创建时间：2018年10月26日 下午2:39:46
 *
 */
@RestController
@RequestMapping(value="/sharer")
public class SharerController {
	@Autowired
	private SharerService sharerService;
	@Autowired
	private CommandBus commandBus;
	
	@Autowired
	private Command<UpdateSharerRequest, Object> updateSharerCommand;
	
	@LoggerOut
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public BaseResponse<QuerySharerListResult> list(@Valid @RequestBody QuerySharerListRequest request) {
		return BaseResponse.success(sharerService.getSharerList(request));
    }
	
	
	@LoggerOut
    @RequestMapping(value = "/updateSharer", method = RequestMethod.POST)
    public BaseResponse<Object> updateSharer(@Valid @RequestBody UpdateSharerRequest request) {
		return commandBus.dispatch(updateSharerCommand, request);
    }
}
